


-- local a = 1;
-- a = a + 1;
-- a = a + 1;
-- print(a);

-- print(coroutine.resume(coroutine.create(function(value)
--     return "==> " .. value;
-- end), "hello world"))

-- print(commonlib.xpcall(function(value)
--     return "==> " .. value;
-- end, "hello world"));

-- function commonlib.async_callback(callback)
--     local xpcall_callback = function(...)
--         return commonlib.xpcall(callback, ...)
--     end
--     return function(...)
--         if (coroutine.isyieldable()) then
--             return xpcall_callback(...);
--         else
--             return coroutine.resume(coroutine.create(xpcall_callback), ...);
--         end
--     end
-- end

-- _G.win = commonlib.ShowVueWindow({
--     url = commonlib.GetFullPath("@script/debugger/test.html"),
-- });


-- if (not commonlib.IsConsoleApplication()) then
--     commonlib.ShowVueWindow({
--         url = commonlib.GetFullPath("@script/debugger/test.html"),
--     });
-- end

-- local luaref = commonlib.MakeLuaRef();
-- luaref:SetRef(function()
--     print("=======")
-- end)
-- print(luaref:GetRef())
-- luaref:SetRef({})
-- print(luaref:GetRef())
-- luaref = nil;
-- collectgarbage()

-- _G.__debugger__();
-- print(commonlib.GetTimeStamp(), _G.coroutine)
-- commonlib.SetTimeout(1000, function()
--     print("==========12")
--     print(commonlib.GetTimeStamp())
--     commonlib.sleep(1000);
--     print(commonlib.GetTimeStamp())
--     print("==========2112")
--     -- timer:Stop();
-- end)
-- commonlib.sleep(3000)
-- print("=======23=======121332")

-- commonlib.SetTimeout(3000, function()
--     print(commonlib.GetTimeStamp())
--     collectgarbage()
-- end)

-- local refkey = window:GetRefKey();
-- local ref = window:GetRef();
-- ref.key = 1;
-- print("===ref_key", window:GetRefKey())
-- print("===ref", window:GetRef());
-- print("===ref --", _G[refkey])

-- local ref = commonlib.LuaRef();
-- local refkey = ref:GetRefKey();
-- local refkey_value = _G[refkey];
-- local refref = ref:GetRef();
-- print(refkey)
-- print(refref)
-- commonlib.xpcall(function()
--     ref:Set("key", "hello world");
--     print(ref:Get("key"));
-- end)
-- commonlib.echo(refkey_value)

-- print(refref)
-- commonlib.SetInterval(2000, function()
--     print("===ref --", _G[refkey])
-- end);
-- print("-------------")
-- print(coroutine.isyieldable())
-- commonlib.sleep(2000)
-- -- commonlib.Sleep(2000)
-- print("============")
-- commonlib.SetTimeout(1000, function()
--     print(coroutine.running())
--     print(coroutine.isyieldable())
--     print("===SetTimeout CallBack");
--     commonlib.Sleep(5000);
--     print("=========Sleep=======")
-- end)

-- local value = commonlib.LuaValue();
-- value:SetRef({key = 1});
-- print(value:GetRef())
-- commonlib.SetTimeout(1000, function()
--     print("=======", _G[id]);
-- end);
-- window:Close();

-- local value = commonlib.LuaValue()
-- value:SetRef({key = 1});

-- _G.LuaPanda = _ENV.import("./LuaPanda.lua")

-- print(commonlib.IsEmscriptenPlatform(), commonlib.IsEmscriptenPlatform() and 9110 or 8818)
-- _G.LuaPanda.start("127.0.0.1", commonlib.IsEmscriptenPlatform() and 9110 or 8818);
-- print("====0")
-- print("====1")

-- print("aA" < "aB", 1/ 2)

-- print (1 == 1 and "aA" < "aB")
-- commonlib.echo(commonlib.sort({1,4, 2, 6, 5}))

-- commonlib.echo(commonlib.FromXmlString(xml_text))

-- _ENV.import("../test/window/test_window.lua");
-- commonlib.echo(LuaPanda.breaks);
-- commonlib.echo(debug.getinfo(1, "Slf"))
-- print("this is a test");

-- print("====================")
-- local socket = lua_extension.luasocket().tcp();
-- print("Connect:", socket:connect("127.0.0.1", 9110));
-- print("Send:", socket:send("hello world"));
-- print("Receive:", socket:receive());
-- print("Receive:", socket:receive());
-- print("===-12")
-- socket:close();

-- local a = 1;

-- print(a)
-- dostring([[
--     print("====dss")
--     commonlib.echo(debug.getinfo(1, "Slf"))
--     print("====dss")
--     print("====dss")
-- ]], 19)

-- function test()
--     print("============fdsf")
--     print("============fdsf")
--     print("============fdsf")
--     commonlib.echo(debug.getinfo(1, "Slf"))
--     print("============fdsf")
--     print("============fdsf")
-- end

-- commonlib.SetTimeout(1, function ()
--     print("=======timer===========")
--     test();
--     commonlib.exit(0);
-- end)
-- print("===========================main.lua==============================")
-- print("===========================main.lua==============================")
-- print("===========================main.lua==============================")
-- print("===========================main.lua==============================")
-- print("===========================main.lua==============================")
-- print("===========================main.lua==============================")
-- print("===========================main.lua==============================")

-- local watch_object = commonlib.NewRootWatchObject();
-- watch_object:NewWatchExpr("return a + b", function(expr_value)
--     print("expr_value", expr_value);
-- end);
-- watch_object:SetKeyValue("a", 1);
-- watch_object:TriggerWatchExprCallback();
-- watch_object:SetKeyValue("b", 2);
-- watch_object:TriggerWatchExprCallback();

-- commonlib.SetTimeout(2000, function()
    -- commonlib.exit();
-- end);

-- local value = __CAPI__.LuaValue();
-- local function func()
--     print(value);
-- end
-- print("value:",  value:GetRef());
-- value:SetRef(func)
-- value = nil;
-- -- print("value:",  value:GetRef());
-- collectgarbage()

-- local env = __CAPI__.LuaEnv({});
-- env:SetRef(1);
-- print(env:GetRef());
-- commonlib.exit();
